<?php
class IndexAction extends Action {
    public function index(){
    	//读取配置
    	$conf=M("Config");
    	$config=$conf->select();
    	$this->assign('config',$config[0]);
    	
    	//读取省级筛选结果
    	$vote=D("Grj");
    	$where['zyz_vote.jtype']=1;
    	$where['zyz_vote.level']=1;
    	$list=$vote->where($where)->join("zyz_vote on zyz_vote.jid=zyz_grj.id")->select();
    	$this->assign("grjlist",$list);
    	$vote=D("Zzj");
    	$where['zyz_vote.jtype']=2;
    	$where['zyz_vote.level']=1;
    	$list=$vote->where($where)->join("zyz_vote on zyz_vote.jid=zyz_zzj.id")->select();
    	$this->assign("zzjlist",$list);
    	$vote=D("Xmj");
    	$where['zyz_vote.jtype']=3;
    	$where['zyz_vote.level']=1;
    	$list=$vote->where($where)->join("zyz_vote on zyz_vote.jid=zyz_xmj.id")->select();
    	$this->assign("xmjlist",$list);
    	
    	//读取专家筛选结果
    	$vote=D("Grj");
    	$where['zyz_vote.jtype']=1;
    	$where['zyz_vote.level']=2;
    	$list=$vote->where($where)->join("zyz_vote on zyz_vote.jid=zyz_grj.id")->select();
    	$this->assign("vgrjlist",$list);
    	$vote=D("Zzj");
    	$where['zyz_vote.jtype']=2;
    	$where['zyz_vote.level']=2;
    	$list=$vote->where($where)->join("zyz_vote on zyz_vote.jid=zyz_zzj.id")->select();
    	$this->assign("vzzjlist",$list);
    	$vote=D("Xmj");
    	$where['zyz_vote.jtype']=3;
    	$where['zyz_vote.level']=2;
    	$list=$vote->where($where)->join("zyz_vote on zyz_vote.jid=zyz_xmj.id")->select();
    	$this->assign("vxmjlist",$list);
    	$this->readContent('公告','gonggao','0,6');
    	$this->readContent('志愿者风采','zyzfc','0,8');
    	$this->readContent('评委会介绍','pwhjs','0,4');
    	$this->readContent('优秀个人奖','yxgrj','');
    	$this->readContent('优秀组织奖','yxzzj','');
    	$this->readContent('优秀项目奖','yxxmj','');
    	$this->display();
    }
    
    function readContent($title,$ass,$limit){
    	$db=M('Content');
    	$where['zyz_class.class_name']=$title;
    	$result=$db->field('zyz_content.id,title,content,from,clicks,imgurl,videourl,ctime,class_name')->join('zyz_class on zyz_class.id=zyz_Content.classid')->where($where)->limit($limit)->select();
    	$this->assign($ass,$result);
    }
}